package com.zmn.oms.zmn.business.impl.redistribute;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zmn.base.engineer.common.dro.foreign.engineer.ForeignEngineerDetailInfoDRO;
import com.zmn.base.engineer.dubbo.interfaces.engineer.cooperate.EngineerCooperateInfoListRemoteService;
import com.zmn.base.engineer.dubbo.interfaces.foreign.EngineerListRemoteService;
import com.zmn.common.dto2.Option;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.common.utils.date.DateUtil;
import com.zmn.common.utils.string.StringUtil;
import com.zmn.consts.GlobalConsts;
import com.zmn.oms.business.interfaces.conf.distributereason.ConfOrderDistributeReasonBService;
import com.zmn.oms.business.interfaces.messageV1.common.MessageSendBaseService;
import com.zmn.oms.business.interfaces.mq.MqProviderService;
import com.zmn.oms.common.annotation.OrderWorkRedistributeLog;
import com.zmn.oms.common.constant.*;
import com.zmn.oms.common.enums.RedistributeStatusEnum;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.bo.conf.distribute.reason.ConfOrderDistributeReasonBO;
import com.zmn.oms.model.bo.work.redistribute.RedistributeBO;
import com.zmn.oms.model.dto.messageV1.AppMessageDTO;
import com.zmn.oms.model.dto.work.modify.OrderDistributeDTO;
import com.zmn.oms.model.entity.masterworking.MasterWorking;
import com.zmn.oms.model.entity.redistribute.OrderWorkRedistributeApply;
import com.zmn.oms.model.entity.redistribute.OrderWorkRedistributeInfo;
import com.zmn.oms.model.entity.work.OrderWork;
import com.zmn.oms.model.vo.work.ZsOrderDistributeVO;
import com.zmn.oms.services.interfaces.masterworking.MasterWorkingService;
import com.zmn.oms.services.interfaces.redistribute.OrderWorkRedistributeApplyService;
import com.zmn.oms.services.interfaces.redistribute.OrderWorkRedistributeInfoService;
import com.zmn.oms.services.interfaces.work.OrderWorkService;
import com.zmn.oms.zmn.business.interfaces.redistribute.OrderWorkRedistributeBService;
import com.zmn.oms.zmn.business.interfaces.work.customwork.ZsCustomWorkBService;
import com.zmn.oms.zmn.business.interfaces.work.customwork.ZsDistributeWorkBService;
import com.zmn.track.common.constant.TrackConfigConsts;
import com.zmn.track.dubbo.dto.TrackWorkDIO;
import com.zmn.track.dubbo.interfaces.trackwork.TrackWorkModifyRemoteService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 类描述: 工单改派业务实现类
 *
 * @author: HuangChao
 * @since: 2022/05/10 16:18
 */
@Slf4j
@Service
public class OrderWorkRedistributeBServiceImpl implements OrderWorkRedistributeBService {

    @Autowired
    private OrderWorkRedistributeApplyService orderWorkRedistributeApplyService;
    @Autowired
    private OrderWorkRedistributeInfoService orderWorkRedistributeInfoService;
    @Autowired
    private MessageSendBaseService messageSendBaseService;
    @Autowired
    private MasterWorkingService masterWorkingService;
    @Autowired
    private ZsCustomWorkBService zsCustomWorkBService;
    @Autowired
    private ConfOrderDistributeReasonBService confOrderDistributeReasonBService;
    @Autowired
    private ZsDistributeWorkBService zsDistributeWorkBService;
    @Autowired
    private OrderWorkService orderWorkService;
    @Autowired
    private MqProviderService mqProviderService;

    @DubboReference(version = com.zmn.base.engineer.common.constants.DubboConsts.INTERFACE_VERSION, check = false)
    protected EngineerListRemoteService engineerListRemoteService;
    @DubboReference(version = com.zmn.track.dubbo.consts.DubboConsts.INTERFACE_VERSION, check = false)
    private TrackWorkModifyRemoteService trackWorkModifyRemoteService;
    @DubboReference(version = com.zmn.base.engineer.common.constants.DubboConsts.INTERFACE_VERSION, check = false)
    private EngineerCooperateInfoListRemoteService engineerCooperateInfoListRemoteService;

    @Override
    @OrderWorkRedistributeLog(type = OrderWorkRedistributeLogConsts.ORDER_REDISTRIBUTE_LOG_TYPE_REDISTRIBUTE, beforeProceed = false)
    public void redistribute(RedistributeBO redistributeBO) {
        log.info("工单改派-指定改派参数：{}", JSON.toJSONString(redistributeBO));
        redistributeBO.setRedistributeOperatorLogRemark("");
        redistributeBO.setOperateTime(DateUtil.getNow());
        // 1、数据处理
        OrderWorkRedistributeApply updateApply = redistributeBO.getOrderWorkRedistributeApply();
        OrderWorkRedistributeInfo info = null;

        // 2、派单处理
        String failCause = null;
        log.debug("redistribute#getEngineerDetailById 入参 [{}]", redistributeBO.getRedistributeMasterId());
        ResponseDTO<ForeignEngineerDetailInfoDRO> responseDTO = engineerListRemoteService.getEngineerDetailById(redistributeBO.getRedistributeMasterId());
        log.debug("redistribute#getEngineerDetailById 出参 [{}]", JSON.toJSONString(responseDTO));
        ForeignEngineerDetailInfoDRO baseEngineerDRO = responseDTO.getData();
        if (!responseDTO.isSuccess() || baseEngineerDRO == null) {
            // 工程师获取失败
            log.info("根据工程师id【{}】获取工程师消息失败:{}", redistributeBO.getRedistributeMasterId(), responseDTO.getMessage());
            updateApply.setRedistributeStatus(RedistributeStatusEnum.REDISTRIBUTE_FAIL.getCode());
            redistributeBO.setRedistributeOperatorLogRemark("获取改派工程师信息失败");
            failCause = "获取改派工程师信息失败";
        } else {
            try {
                ConfOrderDistributeReasonBO reason = confOrderDistributeReasonBService.getConfOrderDistributeReasonById(updateApply.getReasonId());
                info = orderWorkRedistributeInfoService.findRedistributeInfoById(updateApply.getRedistributeId());
                // 派单
                this.distribute(redistributeBO, updateApply, baseEngineerDRO, reason, info);
                updateApply.setRedistributeStatus(RedistributeStatusEnum.REDISTRIBUTE_SUCCESS.getCode());
                updateApply.setRedistributeMasterId(redistributeBO.getRedistributeMasterId());
                updateApply.setRedistributeMasterName(redistributeBO.getRedistributeMasterName());
                updateApply.setDistributeGrid(redistributeBO.getDistributeGrid());
                OrderWork orderWork = orderWorkService.findOrderWorkByKey(updateApply.getOrderId(), updateApply.getWorkId());
                redistributeBO.setRedistributeOperatorLogRemark(this.getRedistributeSuccessRemark(info, baseEngineerDRO, orderWork));
            } catch (Exception e) {
                log.error("工单改派失败：{}", e.getMessage());
                updateApply.setRedistributeStatus(RedistributeStatusEnum.REDISTRIBUTE_FAIL.getCode());
                redistributeBO.setRedistributeOperatorLogRemark(e.getMessage());
                failCause = "未找到满足工程师";
            }
        }

        // 3、更新数据
        updateApply.setUpdater(GlobalConsts.getOperatorTypeName(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        updateApply.setUpdateTime(DateUtil.getNow());
        orderWorkRedistributeApplyService.updateByPrimaryKeySelective(updateApply);

        // 4、更改工单进行中表的状态
        MasterWorking masterWorking = new MasterWorking();
        masterWorking.setWorkId(updateApply.getWorkId());
        masterWorking.setRedistributeStatus(GlobalConsts.YES);
        masterWorkingService.updateRedistributeStatusByKey(masterWorking);

        // 5、发送改派结果给原工程师
        /*if (Objects.equals(updateApply.getReasonId(), ConfDistributeReasonConsts.REASON_TYPE_CATEGORY_WRONG)
                || Objects.equals(updateApply.getReasonId(), ConfDistributeReasonConsts.REASON_TYPE_ADDRESS_WRONG)) {
            // 品类错误和地址错误 在审核通过时 就发送消息
            return;
        }*/
        this.pushRedistributeResultAppMsg(updateApply, info, null, failCause);
    }

    @Override
    @OrderWorkRedistributeLog(type = OrderWorkRedistributeLogConsts.ORDER_REDISTRIBUTE_LOG_TYPE_REDISTRIBUTE_SYSTEM, beforeProceed = false)
    public void autoRedistribute(RedistributeBO redistributeBO) {
        log.info("工单改派-系统改派参数：{}", JSON.toJSONString(redistributeBO));
        redistributeBO.setRedistributeOperatorLogRemark("");
        redistributeBO.setOperateTime(DateUtil.getNow());
        OrderWorkRedistributeApply updateApply = redistributeBO.getOrderWorkRedistributeApply();
        OrderWorkRedistributeInfo info = orderWorkRedistributeInfoService.findRedistributeInfoById(updateApply.getRedistributeId());

        OrderWork orderWork = orderWorkService.findOrderWorkByKeySrcMaster(updateApply.getOrderId(), updateApply.getWorkId());
        // 1、调用系统自动派单 寻找最优工程师
        String failCause = null;
        try {
            if (Objects.nonNull(updateApply.getDutyTime())) {
                // 取传入的预约时间去查询工程师
                orderWork.setDutyTime(updateApply.getDutyTime());
            }
            ZsOrderDistributeVO redistributeMaster = zsDistributeWorkBService.getRedistributeMaster(orderWork, info.getMasterId().intValue());

            if (Objects.isNull(redistributeMaster)) {
                // 系统改派 找不到工程师 流程结束 更新申请记录数据 发起跟单
                updateApply.setRedistributeStatus(RedistributeStatusEnum.REDISTRIBUTE_FAIL.getCode());
                this.addTrack(updateApply, "未找到满足工程师");
                redistributeBO.setRedistributeOperatorLogRemark("未找到满足工程师");
                failCause = "未找到满足工程师";
            } else {
                // 2、派单处理
                log.debug("autoRedistribute#getEngineerDetailById 入参 [{}]", redistributeMaster.getMasterId());
                ResponseDTO<ForeignEngineerDetailInfoDRO> responseDTO = engineerListRemoteService.getEngineerDetailById(redistributeMaster.getMasterId());
                log.debug("autoRedistribute#getEngineerDetailById 出参 [{}]", JSON.toJSONString(responseDTO));
                ForeignEngineerDetailInfoDRO baseEngineerDRO = responseDTO.getData();
                if (!responseDTO.isSuccess() || baseEngineerDRO == null) {
                    // 工程师获取失败
                    log.info("根据工程师id【{}】获取工程师消息失败:{}", redistributeMaster.getMasterId(), responseDTO.getMessage());
                    updateApply.setRedistributeStatus(RedistributeStatusEnum.REDISTRIBUTE_FAIL.getCode());
                    redistributeBO.setRedistributeOperatorLogRemark("获取改派工程师信息失败");
                    failCause = "获取改派工程师信息失败";
                } else {
                    ConfOrderDistributeReasonBO reason = confOrderDistributeReasonBService.getConfOrderDistributeReasonById(updateApply.getReasonId());
                    updateApply.setRedistributeMasterId(redistributeMaster.getMasterId());
                    updateApply.setRedistributeMasterName(redistributeMaster.getMasterName());
                    updateApply.setDistributeGrid(redistributeMaster.getDistributeGrid());
                    redistributeBO.setDistributeGrid(redistributeMaster.getDistributeGrid());
                    updateApply.setRedistributeStatus(RedistributeStatusEnum.REDISTRIBUTE_SUCCESS.getCode());
                    redistributeBO.setRedistributeOperatorLogRemark(this.getRedistributeSuccessRemark(info, baseEngineerDRO, orderWork));
                    //派单
                    this.distribute(redistributeBO, updateApply, baseEngineerDRO, reason, info);
                }
            }

        } catch (Exception e) {
            log.error("工单改派失败：{}", e.getMessage());
            updateApply.setRedistributeStatus(RedistributeStatusEnum.REDISTRIBUTE_FAIL.getCode());
            redistributeBO.setRedistributeOperatorLogRemark(e.getMessage());
            failCause = failCause = "未找到满足工程师";
            ;
            this.addTrack(updateApply, e.getMessage());
        }

        // 4、更新数据
        updateApply.setUpdater(GlobalConsts.getOperatorTypeName(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        updateApply.setUpdateTime(DateUtil.getNow());
        orderWorkRedistributeApplyService.updateByPrimaryKeySelective(updateApply);

        // 5、更改工单进行中表的状态
        MasterWorking masterWorking = new MasterWorking();
        masterWorking.setWorkId(updateApply.getWorkId());
        masterWorking.setRedistributeStatus(GlobalConsts.YES);
        masterWorkingService.updateRedistributeStatusByKey(masterWorking);

        // 6、设置改派操作日志参数
        redistributeBO.setOperatorId(Long.valueOf(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        redistributeBO.setOperator(GlobalConsts.getOperatorTypeName(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        redistributeBO.setOperatorType(GlobalConsts.OPERATE_USER_TYPE_SYSTEM);

        // 7、发送改派结果给原工程师
        /*if (Objects.equals(updateApply.getReasonId(), ConfDistributeReasonConsts.REASON_TYPE_CATEGORY_WRONG)
                || Objects.equals(updateApply.getReasonId(), ConfDistributeReasonConsts.REASON_TYPE_ADDRESS_WRONG)) {
            // 品类错误和地址错误 在审核通过时 就发送消息
            return;
        }*/
        this.pushRedistributeResultAppMsg(updateApply, info, orderWork, failCause);
    }

    @Override
    @OrderWorkRedistributeLog(type = OrderWorkRedistributeLogConsts.ORDER_REDISTRIBUTE_LOG_TYPE_REDISTRIBUTE_REJECT, beforeProceed = false)
    public void redistributeReject(RedistributeBO redistributeBO) {
        log.info("工单改派-系统自动驳回参数：{}", JSON.toJSONString(redistributeBO));
        // 1、更新数据
        OrderWorkRedistributeApply updateApply = redistributeBO.getOrderWorkRedistributeApply();
        updateApply.setRedistributeStatus(RedistributeStatusEnum.CANCEL_REDISTRIBUTE.getCode());
        updateApply.setUpdater(GlobalConsts.getOperatorTypeName(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        updateApply.setUpdateTime(DateUtil.getNow());
        orderWorkRedistributeApplyService.updateByPrimaryKeySelective(updateApply);

        // 更新工单进行中表状态
        MasterWorking masterWorking = new MasterWorking();
        masterWorking.setWorkId(updateApply.getWorkId());
        masterWorking.setRedistributeStatus(GlobalConsts.NONE);
        masterWorkingService.updateRedistributeStatusByKey(masterWorking);

        // 2、发送改派失败消息
        this.pushRedistributeResultAppMsg(updateApply, null, null, "系统自动驳回改派");
        redistributeBO.setOperateTime(DateUtil.getNow());
    }

    /**
     * 派单操作
     *
     * @param redistributeBO
     * @param updateApply
     * @param baseEngineerDRO
     * @param reason
     * @param info
     * @throws OmsBaseException
     */
    private void distribute(RedistributeBO redistributeBO, OrderWorkRedistributeApply updateApply, ForeignEngineerDetailInfoDRO baseEngineerDRO, ConfOrderDistributeReasonBO reason, OrderWorkRedistributeInfo info) throws OmsBaseException {
        // 派单
        OrderDistributeDTO distributeDTO = new OrderDistributeDTO();
        distributeDTO.setOrderId(updateApply.getOrderId());
        distributeDTO.setWorkId(updateApply.getWorkId());
        distributeDTO.setMasterId(baseEngineerDRO.getEngineerId());
        distributeDTO.setMasterName(baseEngineerDRO.getRealName());
        distributeDTO.setMasterPhone(baseEngineerDRO.getMobile());
        distributeDTO.setDistributeGrid(redistributeBO.getDistributeGrid());

        // 设置原工程师
        distributeDTO.setOriginalMasterId(info.getMasterId().intValue());

        // 设置成已派单
        distributeDTO.setStatus(OrderStatusConsts.WORK_STATUS_DISTRIBUTE);
        // 派单路径
        distributeDTO.setDistributeWay(OrderDistributeConsts.DISTRIBUTE_WAY_PLAT);
        // 派单规则
        distributeDTO.setDistributeRule(OrderDistributeConsts.DISTRIBUTE_RULE_SIMPLE);
        // 派单入口
        distributeDTO.setDistributeEntry(OrderDistributeConsts.DISTRIBUTE_ENTRY_REDISTRIBUTE);
        // 责任人归属
        distributeDTO.setLiableType(reason.getLiableType());
        distributeDTO.setDistributeReasonId(reason.getId());
        distributeDTO.setDistributeReason(reason.getReason());

        // 设置日志参数
        this.setDistributeLogParams(distributeDTO, updateApply, redistributeBO);
        zsCustomWorkBService.saveDistribute(distributeDTO);
    }

    /**
     * 设置派单日志参数
     *
     * @param distributeDTO
     * @param updateApply
     * @param redistributeBO
     */
    private void setDistributeLogParams(OrderDistributeDTO distributeDTO, OrderWorkRedistributeApply updateApply, RedistributeBO redistributeBO) {
        distributeDTO.setOperateTime(DateUtil.getNow());
        // 指定改派 有审核，改派人定义为：审核人 无审核，改派人定义为：发起改派的人
        if (Objects.equals(updateApply.getRedistributeType(), ConfRedistributeConsts.REDISTRIBUTE_TYPE_SPECIFY)) {
            if (!Objects.equals(updateApply.getAuditType(), ConfRedistributeConsts.AUDIT_TYPE_NONE)) {
                distributeDTO.setOperatorId(updateApply.getAuditerId());
                distributeDTO.setOperator(updateApply.getAuditer());
                distributeDTO.setOperatorType(redistributeBO.getOperatorType());
                return;
            }

            distributeDTO.setOperator(updateApply.getApplyUser());
            distributeDTO.setOperatorId(updateApply.getApplyUserId());
            distributeDTO.setOperatorType(updateApply.getApplyUserType());
            return;
        }

        // 系统改派，改派人定义为：系统
        distributeDTO.setOperatorId(Long.valueOf(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        distributeDTO.setOperator(GlobalConsts.getOperatorTypeName(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        distributeDTO.setOperatorType(GlobalConsts.OPERATE_USER_TYPE_SYSTEM);
    }

    @Override
    public void pushRedistributeResultAppMsg(OrderWorkRedistributeApply orderWorkRedistributeApply, OrderWorkRedistributeInfo info, OrderWork orderWork, String failCause) {
        log.debug("#pushRedistributeResultAppMsg，={}", JSON.toJSONString(orderWorkRedistributeApply));
        if (Objects.isNull(orderWorkRedistributeApply)) {
            return;
        }

        if (Objects.isNull(orderWork)) {
            orderWork = orderWorkService.findOrderWorkByKey(orderWorkRedistributeApply.getOrderId(), orderWorkRedistributeApply.getWorkId());
        }

        if (Objects.isNull(info)) {
            info = orderWorkRedistributeInfoService.findRedistributeInfoById(orderWorkRedistributeApply.getRedistributeId());
        }

        try {
            // 发送消息通知
            JSONObject params = new JSONObject();
            params.put("product_name", orderWorkRedistributeApply.getProductInfo());
            params.put("order_id", String.valueOf(orderWorkRedistributeApply.getOrderId()));
            params.put("status", RedistributeStatusEnum.getEnumDesc(orderWorkRedistributeApply.getRedistributeStatus()));
            if (StringUtil.isBlank(failCause)) {
                failCause = "null";
            }
            params.put("failCause", failCause);
            if (Objects.equals(orderWorkRedistributeApply.getRedistributeStatus(), RedistributeStatusEnum.REDISTRIBUTE_SUCCESS.getCode())) {
                // 改派成功通知原工程师
                AppMessageDTO appMessageDTO = AppMessageDTO.builder()
                        .orderId(orderWork.getOrderId())
                        .plat(orderWork.getPlatWork())
                        .masterId(info.getMasterId().intValue())
                        .ruleId(MessageConsts.ZMN_MSG_RULEID_REDISTRIBUTE_RESULT)
                        .ruleCode(MessageConsts.ZMN_MSG_RULE_CODE_REDISTRIBUTE_RESULT)
                        .params(params.toJSONString())
                        .build();
                messageSendBaseService.sendAndroidAndIOSMessage(appMessageDTO);

                // 刷新版本号
                mqProviderService.sendEngineerWorkVersion(orderWork.getMasterId(), null);
            } else if (Objects.equals(orderWorkRedistributeApply.getRedistributeStatus(), RedistributeStatusEnum.REDISTRIBUTE_FAIL.getCode())) {
                AppMessageDTO appMessageDTO = AppMessageDTO.builder()
                        .orderId(orderWork.getOrderId())
                        .plat(orderWork.getPlatWork())
                        .masterId(info.getMasterId().intValue())
                        .ruleId(MessageConsts.ZMN_MSG_RULEID_REDISTRIBUTE_RESULT_FAIL)
                        .ruleCode(MessageConsts.ZMN_MSG_RULE_CODE_REDISTRIBUTE_RESULT_FAIL)
                        .params(params.toJSONString())
                        .build();
                messageSendBaseService.sendAndroidAndIOSMessage(appMessageDTO);
            }
        } catch (Exception e) {
            log.error("发送消息失败：{}", e.getMessage());
        }
    }

    /**
     * 发起跟单
     *
     * @param orderWorkRedistributeApply
     * @param remark
     */
    private void addTrack(OrderWorkRedistributeApply orderWorkRedistributeApply, String remark) {
        TrackWorkDIO trackDIO = new TrackWorkDIO();
        trackDIO.setOrderId(orderWorkRedistributeApply.getOrderId());
        trackDIO.setWorkId(orderWorkRedistributeApply.getWorkId());
        trackDIO.setTrackContentId(TrackConfigConsts.TRACK_CONTENT_ID_SYS_REDISTRIBUTE);
        trackDIO.setReasonId(TrackConfigConsts.TRACK_REASON_ID_REDISTRIBUTE_FAIL);
        trackDIO.setOperator(GlobalConsts.getOperatorTypeName(GlobalConsts.OPERATE_USER_TYPE_SYSTEM));
        trackDIO.setOperatorId((long) GlobalConsts.OPERATE_USER_TYPE_SYSTEM);
        trackDIO.setOperatorType(GlobalConsts.OPERATE_USER_TYPE_SYSTEM);
        trackDIO.setOperatorLogRemark(remark);
        ResponseDTO responseDTO = trackWorkModifyRemoteService.addTrack(trackDIO);
        log.info("改派申请-发起跟单，入参：{}，出参：{}", JSON.toJSONString(trackDIO), JSON.toJSONString(responseDTO));
    }

    /**
     * 获取改派成功日志内容
     *
     * @param info
     * @param baseEngineerDRO
     * @return
     */
    private String getRedistributeSuccessRemark(OrderWorkRedistributeInfo info, ForeignEngineerDetailInfoDRO baseEngineerDRO, OrderWork orderWork) {
        StringBuilder sb = new StringBuilder();
        //查询工程师分组信息
        String masterGroupName = null;
        ResponseDTO<Option<Integer>> responseDTO = engineerCooperateInfoListRemoteService.getProductGroupByEngineerIdAndBizType(info.getMasterId().intValue(), orderWork.getBizType());
        if (responseDTO.isSuccess()) {
            masterGroupName = (StringUtils.defaultString(responseDTO.getData().getLabel()));
        }
        sb.append(info.getMasterName()).append("->");
        if (StringUtil.isNotBlank(masterGroupName)) {
            sb.append(masterGroupName).append("-").append(baseEngineerDRO.getRealName());
        }

        // 平台直派
        if (Objects.equals(orderWork.getDistributeWay(), OrderDistributeConsts.DISTRIBUTE_WAY_PLAT)) {
            // 工程师后缀
            if (Objects.equals(baseEngineerDRO.getCooperationType(), GlobalConsts.NO)) {
                sb.append("[直营]");
            } else {
                sb.append("[非直营]");
            }
        }
        return sb.toString();
    }
}
